﻿<Window x:Class="DL.FontViewer.UI.Wpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Windows Font Viewer" 
        Height="600" 
        Width="800">
    <Window.Resources>
        <Style x:Key="DisplayTextBlockStyle" TargetType="{x:Type TextBlock}">
            <Setter Property="FontFamily" Value="{Binding ElementName=FontList, Path=SelectedItem}" />
            <Setter Property="FontStyle" Value="{Binding Path=SelectedFontStyle}" />
            <Setter Property="FontWeight" Value="{Binding Path=SelectedFontWeight}" />
            <Setter Property="Margin" Value="0 0 0 4" /> 
            <Setter Property="Text" Value="{Binding ElementName=SampleText, Path=Text}" />
            <Setter Property="TextWrapping" Value="Wrap" />
        </Style>
    </Window.Resources>

    <Grid Margin="10">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Border Grid.Column="0"
                Grid.Row="0"
                Padding="0 0 0 10">
            <TextBox x:Name="SearchTextBox" 
                     ToolTip="Search fonts (ex: arial)" 
                     KeyDown="SearchTextBox_KeyDown" />    
        </Border>
        
        <Border Grid.Row="0"
                Grid.Column="1" 
                Padding="10 0 0 10" 
                HorizontalAlignment="Left">
            <StackPanel Orientation="Horizontal">
                <Button x:Name="BoldButton" 
                        Width="50" 
                        Content="Bold" 
                        Click="BoldButton_Click" />
                <Button x:Name="ItalicsButton" 
                        Width="50" 
                        Margin="5 0 0 0"
                        Content="Italics" 
                        Click="ItalicsButton_Click" />
                <Button x:Name="ClearButton" 
                        Width="50" 
                        Margin="5 0 0 0" 
                        Content="Clear" 
                        Click="ClearButton_Click" />
            </StackPanel>
        </Border>

        <ListBox x:Name="FontList"
                 Grid.Column="0" 
                 Grid.Row="1"
                 DataContext="{Binding Path=Fonts}"
                 ItemsSource="{Binding}"
                 SelectedItem="{Binding Path=SelectedFont}"
                 Width="200">
            <ListBox.ToolTip>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Path=Count, Mode=OneTime}" />
                    <TextBlock Text=" fonts are installed." />
                </StackPanel>
            </ListBox.ToolTip>
        </ListBox>

        <DockPanel Grid.Column="1" 
                   Grid.Row="1">
            <TextBox x:Name="SampleText"
                     DockPanel.Dock="Bottom"
                     MinLines="4"
                     Margin="8 0"
                     TextWrapping="Wrap"
                     ToolTip="Type here to change the preview text."  
                     Text="The quick brown fox jumps over the lazy dog." />

            <Border Padding="10" 
                    Margin="10 0 0 10"
                    BorderBrush="Gray" 
                    BorderThickness="1">
                <StackPanel>
                    <TextBlock Style="{DynamicResource DisplayTextBlockStyle}"
                               FontSize="10" />
                    <TextBlock Style="{DynamicResource DisplayTextBlockStyle}"
                               FontSize="16" />
                    <TextBlock Style="{DynamicResource DisplayTextBlockStyle}"
                               FontSize="24" />
                    <TextBlock Style="{DynamicResource DisplayTextBlockStyle}"
                               FontSize="32" />
                </StackPanel>
            </Border>
        </DockPanel>
    </Grid>
</Window>
